//
//  GZNetRequest.m
//  Gunz
//
//  Created by Joggy on 16/1/23.
//  Copyright © 2016年 NUPT. All rights reserved.
//

#import "GZNetRequest.h"

@implementation GZNetRequest

+(AFHTTPSessionManager*)getPOSTManager {
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", nil];
    return manager;
}

+(void)upLoadImage {
    UIImage *image = [UIImage imageNamed:@"directions"];
    NSString *url = @"http://120.27.138.167/user/verify";
//    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
//        [formData appendPartWithFileData:UIImagePNGRepresentation(image) name:@"file" fileName:@"image.png" mimeType:@"image/png"];
//    } error:nil];
    
//    NSMutableURLRequest *req = [[NSMutableURLRequest alloc] init];
    
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
    NSURLSessionUploadTask *upload;
    upload = [manager uploadTaskWithRequest:request fromData:UIImagePNGRepresentation(image) progress:nil completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
        NSLog(@"%@", responseObject);
        NSLog(@"%@", error);
    }];
    [upload resume];
//    upload = [manager uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
//        NSLog(@"%@", response);
//        NSLog(@"%@", error);
//    }];
//    [upload resume];
}

+(NSString*)getLoginURL {
    return @"http://180.209.64.49:8001/user/login";
}

+(NSString*)getLoginSessionURL {
    return @"http://120.27.138.167:8000/user/islogin";
}

+(NSString*)getRegisterURL {
    return @"http://180.209.64.49:8001/user/register";
}

+(NSString*)getTaskListURL {
    return @"http://180.209.64.49:8001/task/getListById";
}

+(NSString*)getVerifyURL {
    return @"http://180.209.64.49:8001/user/verify";
}

+(NSString*)getUploadTaskURL {
    return @"http://180.209.64.49:8001/task/uploadTask";
}

@end
